home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 March / EnigmA AMIGA RUN 05 (1996)(G.R. Edizioni)(IT)[!][issue 1996-03][Skylink CD IV].iso / earcd / program / palis102.lha / Palis / src / pl.c < prev    next >
C/C++ Source or Header  |  1992-09-02  |  2KB  |  128 lines

  1. /*
  2.     ·C·O·D·E·X· ·D·E·S·I·G·N· ·S·O·F·T·W·A·R·E·
  3.     presents
  4.  
  5.     Palis
  6.  
  7.     FILE:    pl.c
  8.     TASK:    control stuff
  9.  
  10.     (c)1995 by Hans Bühler
  11. */
  12.  
  13. #include    "pl.h"
  14.  
  15. // ---------------------------
  16. // defines
  17. // ---------------------------
  18.  
  19. // ---------------------------
  20. // datatypes
  21. // ---------------------------
  22.  
  23. // ---------------------------
  24. // proto
  25. // ---------------------------
  26.  
  27. static BOOL InitSys(void);
  28. static void RemSys(void);
  29.  
  30. // ---------------------------
  31. // vars
  32. // ---------------------------
  33.  
  34. #ifndef FINAL
  35.  
  36. struct Library            *CxBase            =    0;
  37. struct MsgPort            *CxPort            =    0;
  38.  
  39. #endif
  40.  
  41. // ---------------------------
  42.  
  43. extern char                *__version        =    PROGNAME_VER,
  44.                             *__procname        =    PROGNAME;
  45.  
  46. // ---------------------------
  47. // funx: init/rem system...
  48. // ---------------------------
  49.  
  50. /***************************************************
  51.  * Alle system-libs, die benötigt werden, öffnen ! *
  52.  ***************************************************/
  53.  
  54. static BOOL InitSys(void)
  55. {
  56.     if(SysBase->LibNode.lib_Version < 37)
  57.         return ErrorReq("AmigaOS V2.04+ required !",0,0,0,0);
  58.  
  59.     if(FindSemaphore(PALIS_SEMAPHORE_NAME))
  60.         return ErrorReq(PROGNAME " is already running !",0,0,0,0);
  61.  
  62. #ifndef FINAL
  63.  
  64.     if(!( CxBase = OpenLibrary("commodities.library",37) ))
  65.     {
  66.         return ErrorReq(    "ERROR: Cannot open commodities.library V37+.",0,0,0,0);
  67.     }
  68.  
  69.     if(!( CxPort  = CreateMsgPort() ))
  70.     {
  71.         return ErrorReq(    " ERROR: Cannot create msgports !",0,0,0,0);
  72.     }
  73.  
  74. #endif
  75.  
  76.     return TRUE;
  77. }
  78.  
  79. /*********************
  80.  * weg mit den allox *
  81.  *********************/
  82.  
  83. static void RemSys(void)
  84. {
  85. #ifndef FINAL
  86.  
  87.     if(CxPort)
  88.     {
  89.         struct Message        *msg;
  90.  
  91.         while(msg = GetMsg(CxPort))
  92.             ReplyMsg(msg);
  93.  
  94.         DeleteMsgPort(CxPort);
  95.     }
  96.  
  97.     if(CxBase)
  98.         CloseLibrary(CxBase);
  99.  
  100. #endif
  101. }
  102.  
  103. // ---------------------------
  104. // funx: main()
  105. // ---------------------------
  106.  
  107. void main(int argc, char *argv[])
  108. {
  109.     if(InitSys())
  110.     {
  111. #ifndef FINAL
  112.         if(InitCom())
  113.         {
  114. #endif
  115.             if(InitMyFunc())
  116.             {
  117.                 MainLoop();
  118.             }
  119.  
  120.             RemMyFunc();
  121. #ifndef FINAL
  122.         }
  123.         RemCom();
  124. #endif
  125.     }
  126.     RemSys();
  127. }
  128.